package com.lagou.rabbitmq.controller;

import com.lagou.rabbitmq.service.PayService;
import com.lagou.rabbitmq.util.SimpleResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

@RestController
public class PayController {

    @Autowired
    private PayService payService;

    @PostMapping("/payment")
    public ResponseEntity pay(@RequestParam @NotNull(message = "用户ID不能为空") Long userId,
                              @RequestParam @NotNull(message = "订单ID不能为空") Long orderId) throws Exception {
        Integer payStatus = payService.pay(userId, orderId);
        return SimpleResponseEntity.post(payStatus);
    }
}
